package com.yugu.encrypt;

import java.util.Random;

/**
 * AESUtil 加解密工具类
 */
public class AESUtil {
    /**
     * 加密用的Key 可以用26个字母和数字组成 此处使用AES-128-CBC加密模式，key需要为16位。
     */
    public static final String skey = "smkldospd121daaa";

    /**
     * 加密偏移量
     */
//    private static final String ivParameter = "1016449182184177";

    /**
     * 加密
     * @param srcData
     * @return
     * @throws Exception
     */
    public static String encrypt(String srcData) throws Exception {
        String enString = AESOperator.getInstance().encrypt(srcData, skey);
        return enString;
    }

    /**
     * 解密
     * @param srcData
     * @return
     * @throws Exception
     */
    public static String decrypt(String srcData) throws Exception {
        String DeString = AESOperator.getInstance().decrypt(srcData, skey);
        return DeString;
    }

    public static void main(String[] args) throws Exception {
        int luckyNumber = new Random().nextInt(10000);
        System.out.println(luckyNumber);
//        String enString = AESUtil.encrypt("f8b6693b0f3211ee982f5254000992901");
//        System.out.println(enString);
//        System.out.println(AESUtil.decrypt("2f36454b73496237343543662b4968756e2b4c69554968375a554e6961726564334262624d76507732424566554e5637516a7a4777467447374c384b4275695430356a696d6b326e5271434c52555a69664c4b5857513d3d"));

    }
}
